Skip to main content

Nushell (Rust) – Eine moderne, plattformübergreifende und leistungsstarke Open-Source Gangster-Shell, die sich aufgemacht hat, den Kushellkurs der Shells zu beenden, indem sie, im Gegensatz zu den traditionellen Shells, technisch ausgefeilte Shellen verteilt. Mit ihren beispiellosen Such-/Filterfunktionen und vielfältigen Ausgabeformaten tischt sie ein Panoptikum an neuen Features auf, die andere Shells so hart in den Schatten stellt, dass diese vor lauter Panik anfangen bei der Ausgabe zu nuschelln. In gewissen Ländern (vor allem auf den Seyshellen) besingen Legenden, dass sogar Paul Mitschell höchstpersönlich zu dieser Shell gegriffen hätte, wenn er nicht falsch abgebogen und Friseur geworden wäre 🙂

Some dirty Features von Nushell:

  • Universelle Anwendung: Nushell cruised gekonnt auf Linux, macOS, BSD und Windows down.
  • Erweiterbarkeit: Mit dem Plugin-System kann man Nushell nach seinem eigenem Gusto erweitern.
  • Datenzentriert: Nushell verwendet strukturierte Daten und Pipelines, was Auswahl, Filterung und Sortierung leichter macht.
  • Fehlermanagement: Nushell arbeitet mit typisierten Daten und bietet klare und präzise Fehlermeldungen, wenn etwas aus demn Ruder walked.
  • Kompatibilität: Nushell versteht JSON, YAML, SQLite, Excel und mehr, was die Integration/Verarbeitung von Daten aus verschiedenen Quellen erleichtert.

Beispiele von Nushell:

# Listet Dateien in einem Verzeichnis auf
ls
╭────┬────────────────┬──────┬─────────┬──────────────╮
│  # │      name      │ type │  size   │   modified   │
├────┼────────────────┼──────┼─────────┼──────────────┤
│  0 │ admin.txt      │ file │ 1.3 KiB │ a year ago   │
│  1 │ analyze        │ dir  │ 4.0 KiB │ 5 months ago │
│  2 │ ansible        │ dir  │ 4.0 KiB │ a year ago   │
│  3 │ bad-ips.log    │ file │   139 B │ a year ago   │
│  4 │ git            │ dir  │ 4.0 KiB │ a year ago   │
│  5 │ go             │ dir  │ 4.0 KiB │ 2 years ago  │
│  6 │ inventory      │ dir  │ 4.0 KiB │ 9 months ago │
│  7 │ ip.txt         │ file │   927 B │ 9 months ago │
│  8 │ programs       │ dir  │ 4.0 KiB │ a year ago   │
│  9 │ scripts        │ dir  │ 4.0 KiB │ 4 months ago │
│ 10 │ server-configs │ dir  │ 4.0 KiB │ 9 months ago │
│ 11 │ server-scripts │ dir  │ 4.0 KiB │ 5 months ago │
│ 12 │ tmp            │ dir  │ 4.0 KiB │ 6 months ago │
╰────┴────────────────┴──────┴─────────┴──────────────╯

# Dateien nach Typ sortieren
ls | sort-by type
╭────┬────────────────┬──────┬─────────┬──────────────╮
│  # │      name      │ type │  size   │   modified   │
├────┼────────────────┼──────┼─────────┼──────────────┤
│  0 │ analyze        │ dir  │ 4.0 KiB │ 5 months ago │
│  1 │ ansible        │ dir  │ 4.0 KiB │ a year ago   │
│  2 │ git            │ dir  │ 4.0 KiB │ a year ago   │
│  3 │ go             │ dir  │ 4.0 KiB │ 2 years ago  │
│  4 │ inventory      │ dir  │ 4.0 KiB │ 9 months ago │
│  5 │ programs       │ dir  │ 4.0 KiB │ a year ago   │
│  6 │ scripts        │ dir  │ 4.0 KiB │ 4 months ago │
│  7 │ server-configs │ dir  │ 4.0 KiB │ 9 months ago │
│  8 │ server-scripts │ dir  │ 4.0 KiB │ 5 months ago │
│  9 │ tmp            │ dir  │ 4.0 KiB │ 6 months ago │
│ 10 │ admin.txt      │ file │ 1.3 KiB │ a year ago   │
│ 11 │ bad-ips.log    │ file │   139 B │ a year ago   │
│ 12 │ ip.txt         │ file │   927 B │ 9 months ago │
╰────┴────────────────┴──────┴─────────┴──────────────╯

# Suche nach einer bestimmten Datei (https://www.nushell.sh/commands/docs/ls.html)
ls | where name == "olum.txt"

# Anzeige aller Systeminformationen (https://www.nushell.sh/commands/docs/sys.html)
sys

# Anzeige der CPU-Infos des Systems (https://www.nushell.sh/commands/docs/sys.html)
sys | get cpu
╭───┬──────┬─────────────────────────────────────────┬──────┬───────────┬──────────────────┬──────────────╮
│ # │ name │                  brand                  │ freq │ cpu_usage │   load_average   │  vendor_id   │
├───┼──────┼─────────────────────────────────────────┼──────┼───────────┼──────────────────┼──────────────┤
│ 0 │ cpu0 │ Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz │  899 │      0.00 │ 0.24, 0.17, 0.39 │ GenuineIntel │
│ 1 │ cpu1 │ Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz │  900 │      0.00 │ 0.24, 0.17, 0.39 │ GenuineIntel │
│ 2 │ cpu2 │ Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz │  899 │      0.00 │ 0.24, 0.17, 0.39 │ GenuineIntel │
│ 3 │ cpu3 │ Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz │  900 │      0.00 │ 0.24, 0.17, 0.39 │ GenuineIntel │
│ 4 │ cpu4 │ Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz │  900 │      0.00 │ 0.24, 0.17, 0.39 │ GenuineIntel │
│ 5 │ cpu5 │ Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz │  900 │      0.00 │ 0.24, 0.17, 0.39 │ GenuineIntel │
│ 6 │ cpu6 │ Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz │  900 │      0.00 │ 0.24, 0.17, 0.39 │ GenuineIntel │
│ 7 │ cpu7 │ Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz │  901 │      0.00 │ 0.24, 0.17, 0.39 │ GenuineIntel │
╰───┴──────┴─────────────────────────────────────────┴──────┴───────────┴──────────────────┴──────────────╯

# Anzeigen der Prozesse die mehr als 50MB Ram verhuren (https://www.nushell.sh/commands/docs/ps.html)
ps | where mem > 50MB                                                                                                                                          
╭────┬───────┬───────┬───────────────────────────────┬──────────┬──────┬───────────┬───────────╮
│  # │  pid  │ ppid  │             name              │  status  │ cpu  │    mem    │  virtual  │
├────┼───────┼───────┼───────────────────────────────┼──────────┼──────┼───────────┼───────────┤
│  0 │   386 │     1 │ /lib/systemd/systemd-journald │ Sleeping │ 0.00 │  83.4 MiB │ 169.2 MiB │
│  1 │  1285 │     1 │ /usr/sbin/clamd               │ Sleeping │ 0.00 │   1.3 GiB │   1.6 GiB │
│  2 │  2242 │     1 │ /usr/sbin/mysqld              │ Sleeping │ 0.00 │   1.1 GiB │   8.8 GiB │
│  3 │  2274 │     1 │ rspamd:                       │ Sleeping │ 0.00 │  82.7 MiB │ 228.0 MiB │
│  4 │  2495 │ 15679 │ /usr/sbin/apache2             │ Sleeping │ 0.00 │  90.9 MiB │ 756.1 MiB │
│  5 │  2736 │  2274 │ rspamd:                       │ Sleeping │ 0.00 │ 118.6 MiB │ 249.5 MiB │
│  6 │  2738 │  2274 │ rspamd:                       │ Sleeping │ 0.00 │ 107.7 MiB │ 237.7 MiB │
│  7 │  2739 │  2274 │ rspamd:                       │ Sleeping │ 0.00 │ 117.7 MiB │ 244.9 MiB │
│  8 │  2740 │  2274 │ rspamd:                       │ Sleeping │ 0.00 │ 118.0 MiB │ 244.9 MiB │
│  9 │  2741 │  2274 │ rspamd:                       │ Sleeping │ 0.00 │ 117.6 MiB │ 244.9 MiB │
│ 10 │  2742 │  2274 │ rspamd:                       │ Sleeping │ 0.00 │ 117.9 MiB │ 244.9 MiB │
│ 11 │  2743 │  2274 │ rspamd:                       │ Sleeping │ 0.00 │  72.8 MiB │ 228.0 MiB │
│ 12 │ 11359 │     1 │ /usr/sbin/apache2             │ Sleeping │ 0.00 │  55.3 MiB │ 744.5 MiB │
╰────┴───────┴───────┴───────────────────────────────┴──────────┴──────┴───────────┴───────────╯

# Anzeigen der Umgebungsvariablen (https://www.nushell.sh/commands/categories/env.html)
env

# Zeigt die aktuelle Uhrzeit in einer Tabelle an
date now | date to-table
╭───┬──────┬───────┬─────┬──────┬────────┬────────┬────────────┬──────────╮
│ # │ year │ month │ day │ hour │ minute │ second │ nanosecond │ timezone │
├───┼──────┼───────┼─────┼──────┼────────┼────────┼────────────┼──────────┤
│ 0 │ 2024 │     2 │  17 │   18 │      6 │     38 │  981569777 │ +01:00   │
╰───┴──────┴───────┴─────┴──────┴────────┴────────┴────────────┴──────────╯

# Anzeige der Festplattennutzung (https://www.nushell.sh/commands/docs/du.html)
du /var/ --max-depth 1                                                                                                                                                                                                                                                                                                                           
╭───┬──────┬───────────┬───────────┬────────────────────────────────────────────────────────────────────────┬───────╮
│ # │ path │ apparent  │ physical  │                              directories                               │ files │
├───┼──────┼───────────┼───────────┼────────────────────────────────────────────────────────────────────────┼───────┤
│ 0 │ /var │ 581.7 MiB │ 581.9 MiB │ ╭────┬─────────────────┬───────────┬───────────┬─────────────┬───────╮ │       │
│   │      │           │           │ │  # │      path       │ apparent  │ physical  │ directories │ files │ │       │
│   │      │           │           │ ├────┼─────────────────┼───────────┼───────────┼─────────────┼───────┤ │       │
│   │      │           │           │ │  0 │ /var/cache      │   4.2 KiB │   8.0 KiB │             │       │ │       │
│   │      │           │           │ │  1 │ /var/monit      │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │  2 │ /var/mail       │ 509.4 MiB │ 509.5 MiB │             │       │ │       │
│   │      │           │           │ │  3 │ /var/backups    │  20.4 MiB │  20.6 MiB │             │       │ │       │
│   │      │           │           │ │  4 │ /var/crash      │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │  5 │ /var/log        │  51.8 MiB │  51.8 MiB │             │       │ │       │
│   │      │           │           │ │  6 │ /var/vmail      │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │  7 │ /var/tmp        │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │  8 │ /var/lib        │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │  9 │ /var/local      │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │ 10 │ /var/opt        │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │ 11 │ /var/lost+found │  16.0 KiB │  16.0 KiB │             │       │ │       │
│   │      │           │           │ │ 12 │ /var/osquery    │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │ 13 │ /var/www        │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ │ 14 │ /var/spool      │   4.0 KiB │   4.0 KiB │             │       │ │       │
│   │      │           │           │ ╰────┴─────────────────┴───────────┴───────────┴─────────────┴───────╯ │       │
╰───┴──────┴───────────┴───────────┴────────────────────────────────────────────────────────────────────────┴───────╯

# Ausführen eines Befehls im Hintergrund (https://www.nushell.sh/commands/docs/start.html)
start {command}

# Anzeigen der Hilfe für einen bestimmten Befehl (https://www.nushell.sh/commands/docs/help.html)
help command_name